//
//  ViewController.m
//  dispatchqueueDemo
//
//  Created by Mac on 16/1/7.
//  Copyright © 2016年 riverlj. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    /*
    dispatch_queue_t mySerialDispatchQue = dispatch_queue_create("com.river.dispatchQueue", NULL);
    dispatch_async(mySerialDispatchQue, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"111111111");
        }
    });
    dispatch_async(mySerialDispatchQue, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"222222222");
        }
    });
    dispatch_async(mySerialDispatchQue, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"333333333");
        }
    });
    dispatch_async(mySerialDispatchQue, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"444444444");
        }
    });
    
    */
    
//    dispatch_queue_t myConcurrentDispatchQue = dispatch_queue_create("com.river.currdispatchQueue", DISPATCH_QUEUE_CONCURRENT);
//    
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"1111111111");
//        }
//    });
//    
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"222222222");
//        }
//    });
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"333333333");
//        }
//    });
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"444444444");
//        }
//    });
//    
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"555555555");
//        }
//    });
//
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"6666666666");
//        }
//    });
//
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"777777777");
//        }
//    });
//
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"8888888888");
//        }
//    });
//
//    dispatch_async(myConcurrentDispatchQue, ^{
//        for (int i=0; i<2000; i++) {
//            NSLog(@"9999999999");
//        }
//    });
//
    
    

    
}

-(void)demo2{
    
    dispatch_queue_t mySerialDispatchQueue = dispatch_queue_create("com.river.myserialdispatchqueue", NULL);
    
    dispatch_queue_t mySerialDispatchQueue2 = dispatch_queue_create("com.river.myserialdispatchqueue2", NULL);
    
    dispatch_queue_t mySerialDispatchQueue3 = dispatch_queue_create("com.river.myserialdispatchqueue3", NULL);
    

    /**
     *  将mySerialDispatchQueue的优先级设置为mySerialDispatchQueue2的优先级，则他俩串行执行
     */
    dispatch_set_target_queue(mySerialDispatchQueue, mySerialDispatchQueue2);
    dispatch_set_target_queue(mySerialDispatchQueue3, mySerialDispatchQueue2);
    
    dispatch_async(mySerialDispatchQueue, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"111111111");
        }
    });
    
    dispatch_async(mySerialDispatchQueue2, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"2222222222");
        }
    });
    
    dispatch_async(mySerialDispatchQueue3, ^{
        for (int i=0; i<2000; i++) {
            NSLog(@"33333333");
        }
    });

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
